//
//  Page_ Diseases.m
//  Food
//
//  Created by dllo on 15/7/19.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "Page_ Diseases.h"
#import "UIImageView+WebCache.h"
@implementation Page__Diseases


- (void)dealloc
{
    [_img release];
    [_myLable release];
    [super dealloc];
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.img = [[[UIImageView alloc] init] autorelease];
//        self.img.backgroundColor = [UIColor redColor];
        [self.contentView addSubview:self.img];
        self.myLable = [[[UILabel alloc] init] autorelease];
        self.myLable.textAlignment = NSTextAlignmentRight;
        self.myLable.font = [UIFont systemFontOfSize:15];
//        self.myLable.backgroundColor = [UIColor greenColor];
        [self.contentView addSubview:self.myLable];
    }
    return self;
}

- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes
{
    [super applyLayoutAttributes:layoutAttributes];
    self.img.frame = CGRectMake(5, 0, layoutAttributes.size.height - 10, layoutAttributes.size.height - 10);
    self.myLable.frame = CGRectMake(self.img.frame.size.width, 0, layoutAttributes.size.width - self.img.frame.size.width - 5, layoutAttributes.size.height);
}

// 重写modelSet方法
- (void)setDiseaseModel:(DiseasesModel *)diseaseModel
{
    if (_diseaseModel != diseaseModel) {
        [_diseaseModel release];
        _diseaseModel = [diseaseModel retain];
    }
#warning 替代图片在这
    [self.img sd_setImageWithURL:[NSURL URLWithString:diseaseModel.imageName]];
    self.myLable.text = diseaseModel.diseaseName;
    
}

@end
